<?php
/**
 * Created by PhpStorm.
 * User: lei
 * Date: 15-6-4
 * Time: 下午9:10
 */
use Phalcon\Mvc\Model;
use Phalcon\Mvc\Model\Validator\Email as EmailValidator;
use Phalcon\Mvc\Model\Validator\Uniqueness as UniquenessValidator;

class Ausers extends Model
{
    public $id;

    public $username;

    public $password;

    public $name;

    public $email;

    public function validation()
    {
        $this->validate(new EmailValidator(array(
            'field' => 'username'
        )));
        $this->validate(new UniquenessValidator(array(
            'field' => 'username',
            'message' => '抱歉，该用户名已被使用'
        )));
        if ($this->validationHasFailed() == true) {
            return false;
        }
    }

}